/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import Principals.Main;
import Model.Turno;
import org.hibernate.Query;
import java.util.*;

/**
 *
 * @author sebastian
 */
public class TurnoDAO {
    
    public static List<Turno> listTurno(){
        Main.usrSesion.session.beginTransaction() ;
        Query query = Main.usrSesion.session.createQuery( "from Turno where estado = 1") ; 
        Main.usrSesion.session.getTransaction().commit() ;
        return query.list() ;
    }
    
    public static Turno getTurnoById( int idx ){
        Main.usrSesion.session.beginTransaction() ;
        Query query = Main.usrSesion.session.createQuery( "from Turno where id_turno = :idTurno" ) ;
        query.setParameter( "idTurno" , idx ) ;
        Main.usrSesion.session.getTransaction().commit() ;
        Turno turno = (Turno)query.uniqueResult() ;
        return turno ;
    }
}
